//
//  TypeRedirector.m
//  Surveyer
//
//  Created by Qikun Guo on 13-8-17.
//  Copyright (c) 2013年 Tim. All rights reserved.
//

#import "TypeRedirector.h"
@implementation TypeRedirector
+ (NSArray *)name
{
    //return @[@"Binary", @"Text Only", @"Text Field", @"Date Picker", @"Slider", @"Picker", @"Multi TF"];
    return @[@"Binary", @"Text Field", @"Slider", @"Picker"];
}

+ (NSInteger)indexOfType:(SurveyItem *)item
{
    NSArray *name = @[@"Binary", @"Text Field", @"Slider", @"Picker"];
    return [name indexOfObject:item.type];
}

+ (dViewController *)viewControllerOfItem:(SurveyItem *)item
{
    dViewController *controller;
    NSString *type = item.type;
    if ([type isEqualToString:@"Binary"])
        controller = [[dBinaryViewController alloc] init];
    else if ([type isEqualToString:@"Text Only"])
        controller = [[dTextOnlyViewController alloc] init];
    else if ([type isEqualToString:@"Text Field"])
        controller = [[dTextFieldViewController alloc] init];
    else if ([type isEqualToString:@"Date Picker"])
        controller = [[dDatePickerViewController alloc] init];
    else if ([type isEqualToString:@"Slider"])
        controller = [[dSliderViewController alloc] init];
    else if ([type isEqualToString:@"Picker"])
        controller = [[dPickerViewController alloc] init];
    else if ([type isEqualToString:@"Multi TF"])
        controller = [[dMultiTFViewController alloc] init];
    
    if (controller)
        controller.currentItem = item;
    return controller;
}

+ (NSDictionary *)dictionaryOfConfiguration:(SurveyItem *)item
{
    NSString *type = item.type;
    if ([type isEqualToString:@"Binary"])
        return @{NSLocalizedString(@"Left", @"binary l"):@"value1", NSLocalizedString(@"Right", @"Binary R"):@"value2"};
    else if ([type isEqualToString:@"Text Only"])
        return @{NSLocalizedString(@"Subtitle", @"type configuration in design"): @"value1"};
    else if ([type isEqualToString:@"Text Field"])
        return @{NSLocalizedString(@"Subtitle", @"type configuration in design"):@"value1"};
    else if ([type isEqualToString:@"Date Picker"])
        return nil;
    else if ([type isEqualToString:@"Slider"])
        return @{NSLocalizedString(@"Min", nil):@"value1", NSLocalizedString(@"Max", nil):@"value2"};
    else if ([type isEqualToString:@"Picker"])
        return @{NSLocalizedString(@"Option1", nil):@"value1", NSLocalizedString(@"Option2", nil):@"value2", NSLocalizedString(@"Option3", nil):@"value3", NSLocalizedString(@"Option4", nil):@"value4"};
    else if ([type isEqualToString:@"Multi TF"])
        return @{NSLocalizedString(@"Option1", nil):@"value1", NSLocalizedString(@"Option2", nil):@"value2", NSLocalizedString(@"Option3", nil):@"value3", NSLocalizedString(@"Option4", nil):@"value4"};
    return 0;
}

+ (NSString *)typeName:(SurveyItem *)item
{
    NSDictionary *dict = @{@"Binary":NSLocalizedString(@"Binary", nil), @"Text Only":NSLocalizedString(@"Text Only", nil), @"Text Field":NSLocalizedString(@"Text Field", nil), @"Date Picker":NSLocalizedString(@"Date Picker", nil), @"Slider":NSLocalizedString(@"Slider", nil), @"Picker":NSLocalizedString(@"Picker", nil), @"Multi TF":NSLocalizedString(@"Multi TF", nil)};
    return [dict objectForKey:item.type];
}
@end